<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>用户登录</title>
    <style>
        /* 设置全局样式 */
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background: linear-gradient(to right, #4facfe, #00f2fe); /* 渐变背景 */
            font-family: Arial, sans-serif;
        }

        /* 登录框 */
        .login-container {
            background: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
            text-align: center;
            width: 350px;
        }

        /* 标题 */
        h2 {
            margin-bottom: 20px;
            color: #333;
        }

        /* 表单样式 */
        form {
            display: flex;
            flex-direction: column;
        }

        /* 输入框 */
        input {
            width: 100%;
            padding: 10px;
            margin: 8px 0;
            border: 1px solid #ccc;
            border-radius: 5px;
            font-size: 16px;
        }

        /* 输入框聚焦时 */
        input:focus {
            outline: none;
            border-color: #4facfe;
        }

        /* 登录按钮 */
        button {
            background: #4facfe;
            color: white;
            padding: 12px;
            font-size: 16px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: 0.3s;
            margin-top: 15px;
        }

        button:hover {
            background: #00c6ff;
        }

        /* 提示信息 */
        .message {
            margin-top: 10px;
            font-size: 14px;
        }

        .error {
            color: red;
        }

        .logout {
            color: green;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <h2>用户登录</h2>

        <form th:action="@{/login}" method="post">
            <input type="text" name="username" placeholder="请输入用户名" required>
            <input type="password" name="password" placeholder="请输入密码" required>
            <button type="submit">登录</button>
        </form>

        <div class="message error" th:if="${param.error}">
            <p>用户名或密码错误</p>
        </div>

        <div class="message logout" th:if="${param.logout}">
            <p>你已成功登出</p>
        </div>
    </div>
</body>
</html>

<!--
✅ 使用 Thymeleaf 解析 Spring Security 的 param.error 和 param.logout
✅ 提交表单到 /login，由 Spring Security 处理 
✅ 输入错误时显示警告信息
-->